package com.newviews.tcmip.web.controller;

import com.newviews.tcmip.pojo.vo.export.EtcmCommonExportReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * <p>
 * 草药-疾病关系表 前端控制器
 * </p>
 *
 * @author lxc
 * @since 2024-03-08
 */
@RestController
@RequestMapping("/etcm/herb/disease")
@Api(tags = "疾病草药相关")
public class EtcmHerbDiseaseController {

    @PostMapping("/download")
    @ApiOperation(value = "疾病草药关联信息下载")
    public void downloadHerb(
            @ApiIgnore HttpServletResponse response,
            @RequestBody @Valid EtcmCommonExportReqVO reqVO) {
        try {
            String path="";
            InputStream stream = new FileInputStream(path);
            ServletOutputStream out = response.getOutputStream();
            byte buff[] = new byte[1024];
            int length = 0;
            while ((length = stream.read(buff)) > 0) {
                out.write(buff, 0, length);
            }
            stream.close();
            out.close();
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {

        }
    }
}
